#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> num(n + 1);
    int max = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> num[i];
        max = max < num[i] ? num[i] : max;
    }
    vector<vector<vector<int>>> pos(n + 1, vector<vector<int>>(11, vector<int>(11)));
    int id = 0;
    int pre = 0;
    for (int j = 1; j <= max; j++)
    {
        for (int k = 1; k <= 10; k++)
        {
            for (int i = 1; i <= n; i++)
            {
                if (j <= num[i])
                {
                    if (pre == i)
                    {
                        id += 2;
                    }
                    else
                    {
                        id += 1;
                    }
                    pre = i;
                    pos[i][j][k] = id;
                }
            }
        }
    }

    for (int i = 1; i <= n; i++)
    {
        cout << "#" << i << endl;
        for (int j = 1; j <= num[i]; j++)
        {
            for (int k = 1; k <= 10; k++)
            {
                cout << pos[i][j][k];
                if (k % 10 != 0)
                    cout << " ";
                else
                    cout << endl;
            }
        }
    }
    return 0;
}